<template>
	<div class="table-body-container layout-padding">
		<el-card shadow="hover" class="layout-padding-auto">
			<div class="system-user-search mb15">
				<el-input size="default" v-model="state.tableData.param.createBy" placeholder="请输入用户名" style="max-width: 180px"> </el-input>
				<el-button size="default" @click="getTableData" type="primary" class="ml10">
					<el-icon>
						<ele-Search />
					</el-icon>
					查询
				</el-button>
			</div>
			<el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
				<el-table-column prop="createBy" label="操作人员" show-overflow-tooltip></el-table-column>
				<el-table-column prop="businessName" label="业务模块" show-overflow-tooltip></el-table-column>
				<el-table-column prop="createDate" label="操作日期" show-overflow-tooltip></el-table-column>
				<el-table-column prop="ip" label="IP地址" show-overflow-tooltip></el-table-column>
				<el-table-column prop="method" label="方法名" show-overflow-tooltip></el-table-column>
				<el-table-column prop="url" label="请求地址" show-overflow-tooltip></el-table-column>
				<el-table-column prop="operParam" label="请求参数" show-overflow-tooltip></el-table-column>
				<el-table-column prop="result" label="返回结果" show-overflow-tooltip></el-table-column>
				<el-table-column prop="logStatus" label="状态" show-overflow-tooltip>
					<template #default="scope">
						<el-tag type="0" v-if="scope.row.logStatus">正常</el-tag>
						<el-tag type="1" v-else>异常</el-tag>
					</template>
				</el-table-column>
			</el-table>
			<pagination
                v-show="state.tableData.total>0"
                :total="state.tableData.total"
                v-model:page="state.tableData.param.current"
                v-model:limit="state.tableData.param.size"
                @pagination="getTableData"
            />
		</el-card>
	</div>
</template>

<script setup lang="ts" name="systemLog">
import { logApi } from '/@/api/system/log';
import constConfig from '/@/utils/constConfig';

// 引入组件

// 定义变量内容
const state = reactive({
	tableData: {
		data: [],
		total: 0,
		loading: false,
		param: {
			createBy:'',
			...constConfig.pageModel,
		},
	},
	deptData: [],
	menuData: [],
	...constConfig.dialogType
});

// 初始化表格数据
const getTableData = () => {
	state.tableData.loading = true;
	logApi().page(state.tableData.param).then(res=>{
		state.tableData.data = res.data.records??[];
		state.tableData.total = res.data.total;
		state.tableData.loading = false;
	})
};
// 页面加载时
onMounted(() => {
	getTableData();
});
</script>
<style scoped lang="scss">
.table-body-container {
	:deep(.el-card__body) {
		display: flex;
		flex-direction: column;
		flex: 1;
		overflow: auto;
		.el-table {
			flex: 1;
		}
	}
}
</style>